/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.Convertion;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.dbaccess.DmMsgSend;
/*     */ import java.sql.SQLException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DmByteArrBinder
/*     */   extends DmBinder
/*     */ {
/*  14 */   boolean new_lob_flag = false;
/*     */   
/*     */   public DmByteArrBinder(DmdbPreparedStatement_bs pstmt)
/*     */   {
/*  18 */     super(pstmt);
/*  19 */     this.new_lob_flag = pstmt.getConnection_bs().getNewLobFlag();
/*     */   }
/*     */   
/*     */   void init()
/*     */   {
/*  24 */     this.recDType = 18;
/*  25 */     this.recPrec = 8188;
/*  26 */     this.recScale = 0;
/*     */   }
/*     */   
/*     */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*     */   {
/*  31 */     byte[] x = ((byte[][])this.pstmt.m_paramObjects[icol])[irow];
/*     */     
/*  33 */     if (this.destDType == 12)
/*     */     {
/*  35 */       if (x.length > 2048) {
/*  36 */         return -1;
/*     */       }
/*  38 */     } else if (this.destDType == 19)
/*     */     {
/*  40 */       if (x.length * 2 > 2048) {
/*  41 */         return -1;
/*     */       }
/*     */     }
/*  44 */     byte[] bs = toDbBytes(x, this.destDType, this.destPrec);
/*     */     
/*  46 */     return msg.appendBytesWithLen2(bs, 0, bs.length);
/*     */   }
/*     */   
/*     */   public static byte[] toDbBytes(byte[] x, int destDType, int destPrec) throws SQLException
/*     */   {
/*  51 */     byte[] bs = null;
/*  52 */     switch (destDType)
/*     */     {
/*     */ 
/*     */     case 17: 
/*  56 */       bs = x;
/*  57 */       break;
/*     */     
/*     */     case 18: 
/*  60 */       bs = x;
/*  61 */       break;
/*     */     
/*     */     case 12: 
/*  64 */       bs = x;
/*  65 */       break;
/*     */     
/*     */     case 19: 
/*  68 */       bs = Convertion.binaryArrToString(x, destPrec, destDType);
/*  69 */       break;
/*     */     
/*     */     case 0: 
/*     */     case 1: 
/*     */     case 2: 
/*  74 */       bs = Convertion.binaryArrToString(x, destPrec, destDType);
/*  75 */       break;
/*     */     default: 
/*  77 */       DBError.throwSQLException(6007); }
/*     */     
/*  79 */     return bs;
/*     */   }
/*     */   
/*     */   public int bindLobCyc(DmMsgSend lobMsg, int irow, int icol) throws SQLException
/*     */   {
/*  84 */     int maxLen = 16000;
/*  85 */     if (this.destDType == 19) {
/*  86 */       maxLen = 8000;
/*     */     }
/*  88 */     byte[] x = ((byte[][])this.pstmt.m_paramObjects[icol])[irow];
/*  89 */     if (this.offset_var >= x.length)
/*     */     {
/*  91 */       clearVars();
/*  92 */       return 0;
/*     */     }
/*     */     
/*  95 */     if (this.offset_var == -1) {
/*  96 */       this.offset_var = 0;
/*     */     }
/*  98 */     int retLen = 0;
/*  99 */     int readLen = x.length - this.offset_var > maxLen ? maxLen : x.length - this.offset_var;
/*     */     
/* 101 */     if (this.destDType == 12) {
/* 102 */       retLen = lobMsg.appendOffRowBytes(x, this.offset_var, readLen, this.new_lob_flag, -1);
/* 103 */     } else if (this.destDType == 19)
/*     */     {
/* 105 */       byte[] cvt = Convertion.binaryArrToClob_bin(x, this.offset_var, readLen);
/* 106 */       retLen = lobMsg.appendOffRowBytes(cvt, 0, cvt.length, this.new_lob_flag, -1);
/*     */     }
/*     */     
/* 109 */     this.offset_var += readLen;
/*     */     
/* 111 */     return retLen;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmByteArrBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */